package minimips.isa.rtype;

import minimips.isa.InstructionSpecification;

public class RTypeSpecification extends InstructionSpecification {

	private int rs, rt, rd, extra, function;
	
	public RTypeSpecification(int opcode, int rs, int rt, int rd, int extra, int function) {
		super(opcode);
		this.rs = rs;
		this.rt = rt;
		this.rd = rd;
		this.extra = extra;
		this.function = function;
	}
	
	public int getRs() {
		return rs;
	}

	public int getRt() {
		return rt;
	}

	public int getRd() {
		return rd;
	}

	public int getExtra() {
		return extra;
	}

	public int getFunction() {
		return function;
	}
	
	public int getMachineCode() {
		int machineCode = this.getOpcode() << 6 | rs;
		machineCode = machineCode << 5 | rt;
		machineCode = machineCode << 5 | rd;
		machineCode = machineCode << 5 | extra;
		machineCode = machineCode << 5 | function;
		return machineCode;
	}

}
